import com.alibaba.fastjson.JSON;
import coupon.CouponResult;
import coupon.CouponService;

import java.util.Map;
import java.util.logging.Logger;

public class CouponCommodityService implements ICommodity
{
	private Logger logger = Logger.getLogger(CouponCommodityService.class.toString());
	private CouponService couponService = new CouponService();
	@Override
	public void sendCommodity(String uId, String commodityId, String bizId, Map<String, String> extMap) throws Exception
	{
		CouponResult couponResult =
						this.couponService.sendCoupon(uId, commodityId, bizId);
		this.logger.info("请求参数[优惠券] => uId：" + uId + "; commodityId：" + commodityId + "; bizId：" + bizId + "; extMap：" + JSON.toJSON(extMap));
		this.logger.info("测试结果[优惠券]：" + JSON.toJSON(couponResult));
		if (!"0000".equals(couponResult.getCode()))
			throw new RuntimeException(couponResult.getInfo());
	}
}
